% TEST_ID: LANG-EXPAND-0046
% CATEGORY: language/struct
% 测试结构体的删改

function test_struct_modify2
    A.field1 = 1;
    A.field2 = 2;
    assert(isequal(A.field1, 1)); % Initial field value
    assert(isequal(A.field2, 2)); % Initial field value

    A.field1(5) = 10; % Modify field1
    assert(isequal(A.field1, [1 0 0 0 10])); % Check modified field1
    assert(isequal(A.field2, 2)); % Check unchanged field2

    A.field3{3} = 20; % Add a new field with a cell array
    assert(isequal(A.field3, {[], [], 20})); % Check new field value
    assert(isfield(A, 'field3')); % Check new field exists
    assert(isequal(fieldnames(A), {'field1'; 'field2'; 'field3'})); % Check field names
end

